/**
 * 询价.COM v1.0.0
 * http://xun-jia.com/
 *
 * Copyright (c) 2009 
 * 四川漾天空网络科技有限公司
 * 成都市天府软件园A3栋2楼
 *
 */
package com.xunjia.purchase.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Action;
import com.xunjia.action.XunJiaActionSupport;
import com.xunjia.util.StringUtil;
import com.yam.michael.hibernate.pojo.KeywordsAdvInfo;

/**
 * @author Mark
 * 
 * @Email Mark_yang@xun-jia.com
 * 
 * @Date 2009-4-2 下午04:34:59
 * 
 */
public class PurchaseAction extends XunJiaActionSupport {

	private static final long serialVersionUID = -8182944359355697641L;
	// 日誌
	private static final Logger logger = Logger.getLogger(PurchaseAction.class);
	// 每頁顯示數據條數
	private static final int pageSize = 6;
	// 下一步
	private static final String NEXTSTEP = "NEXT_STEP";
	/** 搜索页面 */
	// 關鍵字
	private String key;
	// 搜索結果列表
	private List<KeywordsAdvInfo> searchList;

	/** 添加关键字广告 */
	// 关键字
	private String keywordsStr;
	// 关键字数组
	private String keywords;
	// 对比方式
	private String compare;
	// 一般 关键字广告
	private String general;
	// 内容对比广告
	private String comparison;
	// 广告活动名
	private String adname;
	// 是否跳出价页
	private String forward;
	/** 出价 */
	private String price;

	/** 广告内容设置 */
	private String validdate;
	private String link;
	private String content;
	private String additional;
	private String title;

	/**
	 * 关键字广告搜索
	 * 
	 * @return
	 * @throws Exception
	 */
	public String search() throws Exception {
		searchList = new ArrayList<KeywordsAdvInfo>();
		for (int i = 0; i < pageSize; i++) {
			KeywordsAdvInfo key = new KeywordsAdvInfo();
			key.setContent("行動電話\\移動電話\\通訊\\移動通訊");
			key.setHref("#");
			//key.setKeywords("手機");
			//key.setPrice(22.5);
			key.setTitle("行動電話\\移動電話\\通訊\\移動通訊");
			//key.setOwner_userId("TC0001");
			searchList.add(key);
		}
		return Action.SUCCESS;
	}

	/**
	 * 添加关键字
	 * 
	 * @return
	 * @throws Exception
	 */
	public String addKeywords() throws Exception {
		if (StringUtil.isEmpty(general) && StringUtil.isEmpty(comparison)) {
			addFieldError("adtype", "至少选择一种广告类型");
			return Action.INPUT;
		}
		if (!NEXTSTEP.equals(forward)) {
			return Action.INPUT;
		}
		return Action.SUCCESS;
	}

	/**
	 * 出价
	 * 
	 * @return
	 * @throws Exception
	 */
	public String purchase() throws Exception {
		if (!NEXTSTEP.equals(forward)) {
			return Action.INPUT;
		}
		return Action.SUCCESS;
	}

	/**
	 * 支付广告费
	 * 
	 * @return
	 * @throws Exception
	 */
	public String pay() throws Exception {
		if (!NEXTSTEP.equals(forward)) {
			return Action.INPUT;
		}
		return Action.SUCCESS;
	}

	/**
	 * @return the key
	 */
	public String getKey() {
		return key;
	}

	/**
	 * @param key
	 *            the key to set
	 */
	public void setKey(String key) {
		this.key = key;
	}

	/**
	 * @return the general
	 */
	public String getGeneral() {
		return general;
	}

	/**
	 * @param general
	 *            the general to set
	 */
	public void setGeneral(String general) {
		this.general = general;
	}

	/**
	 * @return the keywords
	 */
	public String getKeywords() {
		return keywords;
	}

	/**
	 * @param keywords
	 *            the keywords to set
	 */
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	/**
	 * @return the comparison
	 */
	public String getComparison() {
		return comparison;
	}

	/**
	 * @param comparison
	 *            the comparison to set
	 */
	public void setComparison(String comparison) {
		this.comparison = comparison;
	}

	/**
	 * @return the forward
	 */
	public String getForward() {
		return forward;
	}

	/**
	 * @param forward
	 *            the forward to set
	 */
	public void setForward(String forward) {
		this.forward = forward;
	}

	/**
	 * @return the keywordsStr
	 */
	public String getKeywordsStr() {
		return keywordsStr;
	}

	/**
	 * @param keywordsStr
	 *            the keywordsStr to set
	 */
	public void setKeywordsStr(String keywordsStr) {
		this.keywordsStr = keywordsStr;
	}

	/**
	 * @return the searchList
	 */
	public List getSearchList() {
		return searchList;
	}

	/**
	 * @return the compare
	 */
	public String getCompare() {
		return compare;
	}

	/**
	 * @param compare
	 *            the compare to set
	 */
	public void setCompare(String compare) {
		this.compare = compare;
	}

	/**
	 * @return the adname
	 */
	public String getAdname() {
		return adname;
	}

	/**
	 * @param adname
	 *            the adname to set
	 */
	public void setAdname(String adname) {
		this.adname = adname;
	}

	/**
	 * @return the price
	 */
	public String getPrice() {
		return price;
	}

	/**
	 * @param price
	 *            the price to set
	 */
	public void setPrice(String price) {
		this.price = price;
	}

	/**
	 * @return the validdate
	 */
	public String getValiddate() {
		return validdate;
	}

	/**
	 * @param validdate
	 *            the validdate to set
	 */
	public void setValiddate(String validdate) {
		this.validdate = validdate;
	}

	/**
	 * @return the link
	 */
	public String getLink() {
		return link;
	}

	/**
	 * @param link
	 *            the link to set
	 */
	public void setLink(String link) {
		this.link = link;
	}

	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * @return the additional
	 */
	public String getAdditional() {
		return additional;
	}

	/**
	 * @param additional
	 *            the additional to set
	 */
	public void setAdditional(String additional) {
		this.additional = additional;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @param searchList
	 *            the searchList to set
	 */
	public void setSearchList(List<KeywordsAdvInfo> searchList) {
		this.searchList = searchList;
	}
}
